package com.a3dweijing.wetouch2.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.a3dweijing.wetouch2.Common.CallBack;
import com.a3dweijing.wetouch2.R;
import com.a3dweijing.wetouch2.Util.GlideUtil;
import com.a3dweijing.wetouch2.bean.HomeVideoMsg;
import com.a3dweijing.wetouch2.bean.ReportInfoMSg;

import java.util.List;

/**
 * Created by Yxd on 2018/3/22.
 */

public class HomeVideoAdapter extends RecyclerView.Adapter<HomeVideoAdapter.MyViewHolder> {
    List<HomeVideoMsg.VideoBean> beans;
    CallBack callBack;
    Context context;

    public HomeVideoAdapter(List<HomeVideoMsg.VideoBean> beans, CallBack callBack) {
        this.beans = beans;
        this.callBack = callBack;
    }

    @Override
    public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new MyViewHolder(LayoutInflater.from(context=parent.getContext()).inflate(R.layout.item_home_video,parent,false));
    }

    @Override
    public void onBindViewHolder(MyViewHolder holder, final int position) {
        GlideUtil.getInstance().showImage(context,"https://lfriend.oss-cn-shenzhen.aliyuncs.com/upload/"+beans.get(position).getVideoShowImg(),holder.pic);
        holder.name.setText("【3D观看】"+beans.get(position).getVideoName());
        holder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (callBack!=null ){
                    callBack.doNext(position,beans.get(position));
                }
            }
        });
    }

    @Override
    public int getItemCount() {
        return beans.size();
    }

    class MyViewHolder extends RecyclerView.ViewHolder {
        ImageView pic;
        TextView name;
        public MyViewHolder(View itemView) {
            super(itemView);
            pic=itemView.findViewById(R.id.home_video_img);
            name=itemView.findViewById(R.id.home_video_name);
        }
    }
}
